package com.gxkj.projects.myschoolx.binlog.service.impl;



import com.gxkj.projects.myschoolx.binlog.entitys.MyUser;
import com.gxkj.projects.myschoolx.binlog.mapper.MyUserMapper;
import com.gxkj.projects.myschoolx.binlog.service.MyUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class MyUserServiceImpl implements MyUserService {

    @Autowired
    private MyUserMapper test1Mapper;

    @Override
    public void doAddWithoutError(MyUser entity1) {
        test1Mapper.addEntity(entity1);
    }

    @Override
    public void doAddWithError(MyUser entity1) {
        test1Mapper.addEntity(entity1);
        throw new IllegalArgumentException("事务测试，期望回滚");
    }

    @Override
    public void doUpdate(MyUser entity1) {
        test1Mapper.updateEntity(entity1);
    }

    @Override
    public void doUpdateWithError(MyUser entity) {
        test1Mapper.updateEntity(entity);
        throw new IllegalArgumentException("事务测试，期望回滚");
    }

    @Override
    public void doDelete(int  id) {
        test1Mapper.deleteById(id);

    }

    @Override
    public void doDeleteWithError(int id) {
        test1Mapper.deleteById(id);
        throw new IllegalArgumentException("删除时事务测试，期望回滚");
    }

    @Override
    public MyUser findById(int id) {
           return test1Mapper.findById(id);
    }
}
